/**
 ******************************************************************************
 * @file    ringbuf.h
 * @author  chengbb
 * @version V1.0
 * @date    2017-01-18
 * @brief   环形缓冲操作头文件
 ******************************************************************************
 * @attention
 *
 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
 *
 * <h2><center>&copy; COPYRIGHT 2016 MindX</center></h2>
 ******************************************************************************
 */
/** @addtogroup BSP
* @{
*/
#ifndef __RINGBUF_H__
#define __RINGBUF_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "stm32f10x.h"

/*环形缓冲区结构体*/
typedef struct
{
	uint8_t* buf;   	 /*串口环形缓冲区地址*/   
	uint16_t buf_size;   /*环形缓冲区大小*/
	uint16_t iwrite;     /*写入缓冲区偏移地址*/
	uint16_t iread;      /*读缓冲区偏移地址*/
}RingBuf_T;

void ringbuf_init(RingBuf_T* buf_t, uint8_t* buf, uint16_t buf_size);
int ringbuf_write(RingBuf_T* buf_t, uint8_t ch);
int ringbuf_hasdata(RingBuf_T* buf_t);
int ringbuf_datalen(RingBuf_T* buf_t);
int ringbuf_read(RingBuf_T* buf_t);
int ringbuf_datalen(RingBuf_T* buf_t);


#endif

/**
  * @}
  */
/******************* (C) COPYRIGHT 2017 MINDX ******END OF FILE******************/
